package com.sj.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 菜单表
 * </p>
 *
 * @author 孙峻
 * @since 2022-03-09
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("sys_menu")
@ApiModel(value = "SysMenu对象", description = "菜单表")
public class SysMenu implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("菜单id 自增长")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("父菜单id 如果没有为0")
    private Integer parentId;

    @ApiModelProperty("菜单名")
    private String name;

    @ApiModelProperty("菜单路径")
    private String path;

    @ApiModelProperty("权限")
    private String perms;

    @ApiModelProperty("组件路径")
    private String componentPath;

    @ApiModelProperty("类型 0 目录 1 菜单 2 按钮")
    private Integer type;

    @ApiModelProperty("图标")
    private String icon;

    @ApiModelProperty("排序")
    private Integer orderNum;

    @ApiModelProperty("是否删除 1 删除 0 未删除")
    @TableLogic
    private Boolean del;

    @ApiModelProperty("是否启用 1 启用 0 禁用")
    private Boolean status;

    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime updateTime;

    public static SysMenuBuilder builder() {
        return new SysMenuBuilder();
    }


    public static final class SysMenuBuilder {
        private Integer id;
        private Integer parentId;
        private String name;
        private String path;
        private String perms;
        private String componentPath;
        private Integer type;
        private String icon;
        private Integer orderNum;
        private Boolean del;
        private Boolean status;
        private LocalDateTime createTime;
        private LocalDateTime updateTime;

        private SysMenuBuilder() {
        }

        public SysMenuBuilder id(Integer id) {
            this.id = id;
            return this;
        }

        public SysMenuBuilder parentId(Integer parentId) {
            this.parentId = parentId;
            return this;
        }

        public SysMenuBuilder name(String name) {
            this.name = name;
            return this;
        }

        public SysMenuBuilder path(String path) {
            this.path = path;
            return this;
        }

        public SysMenuBuilder perms(String perms) {
            this.perms = perms;
            return this;
        }

        public SysMenuBuilder componentPath(String componentPath) {
            this.componentPath = componentPath;
            return this;
        }

        public SysMenuBuilder type(Integer type) {
            this.type = type;
            return this;
        }

        public SysMenuBuilder icon(String icon) {
            this.icon = icon;
            return this;
        }

        public SysMenuBuilder orderNum(Integer orderNum) {
            this.orderNum = orderNum;
            return this;
        }

        public SysMenuBuilder del(Boolean del) {
            this.del = del;
            return this;
        }

        public SysMenuBuilder status(Boolean status) {
            this.status = status;
            return this;
        }

        public SysMenuBuilder createTime(LocalDateTime createTime) {
            this.createTime = createTime;
            return this;
        }

        public SysMenuBuilder updateTime(LocalDateTime updateTime) {
            this.updateTime = updateTime;
            return this;
        }

        public SysMenu build() {
            SysMenu sysMenu = new SysMenu();
            sysMenu.setId(id);
            sysMenu.setParentId(parentId);
            sysMenu.setName(name);
            sysMenu.setPath(path);
            sysMenu.setPerms(perms);
            sysMenu.setComponentPath(componentPath);
            sysMenu.setType(type);
            sysMenu.setIcon(icon);
            sysMenu.setOrderNum(orderNum);
            sysMenu.setDel(del);
            sysMenu.setStatus(status);
            sysMenu.setCreateTime(createTime);
            sysMenu.setUpdateTime(updateTime);
            return sysMenu;
        }
    }
}
